package org.windey.server;

import java.io.IOException;
import java.net.ServerSocket;

/**
 * 
 * 
 *
 */
public class AppletConnectThread extends ConnectThread
{
	/**
	 * 
	 */
	private ServerSocket connectSocket;
	
	/**
	 * 
	 * @param port
	 * @param server
	 */
	public AppletConnectThread(int port, WindeyServer server)
	{
		super(port, server);
	}
	
	/**
	 * 
	 */
	public void run()
	{
		try
		{
			connectSocket = new ServerSocket(this.getListenPort());
			System.out.println("connect thread started on port " + this.getListenPort());
			AppletConnection ac;
			while (this.getRunning())
			{
				ac = new AppletConnection(connectSocket.accept());
				ac.start();
				this.getServer().addAppletConnection(ac);
			}
			connectSocket.close();
		}
		catch (IOException e)
		{
			System.err.println("Could not listen on port " + this.getListenPort());
			//System.exit(-1);
		}
	}
}
